<?php

// Prevent much happening if this script is called directly
if ( !defined('INCS') ) exit;

// Configuration for contact form


// Email configuration

$email_config = array(

    // Setting this to an email address will prevent the form from sending mail
    // to any address except the one defined here.  Useful whilst testing the form.
    'email_test_mode' => '',

    // Emails sent via the form will come from the following address
    'sendmail_from' => 'do_not_reply@example.com',
    'subject' => 'Contact message from website.',

    //
    'email_recipients' => array(
        1 => 'user_1@example.com',
        2 => 'user_2@example.com',
        3 => 'user_3@example.com'
    )
);



// Submission trigger
// The value of the trigger is the name of the form element responsible for
// causing form to be submitted.  e.g. <input name="submit" type="submit" ...
// Used to decide if the form has been submitted using the trigger

$submission_trigger = "submit";



// Form set-up
// Defines the properties of the form.

$form_config = array(

    'form_action' => 'contact.php',
    'form_method' => 'POST',
    'form_attributes' => 'id="ContactForm"',
    'form_legend' => 'Quick contact form',
    'form_legend_attributes' => '',
    'form_controls_wrapper_tagname' => 'div',
    'form_controls_wrapper_attributes' => '',
    'form_submission_method' => array(
        'tagname' => 'input',
        'name' => 'submit',
        'type' => 'submit',
        'attributes' => 'id="button"',
        'value' => 'SEND'
    )
);



// Form element set-up
// Defines the properties of a number of form elements, each of which will be
// inserted into the form when it is displayed.

$controls_config = array(

    'Name' => array(
        'tagname' => 'input', 'type' => 'text',
        'wrapper_tag' => 'div', 'wrapper_attributes' => 'class="input"',
        'label' => 'Your Name', 'label_attributes' => '',
        'attributes' => 'type="text" maxlength="256"',
        'err_field_transform' => 'type="text" maxlength="256" class="field_error"',
        'err_wrap_tag' => 'div', 'err_wrap_attributes' => 'class="form_error"',
        'validate' => array('non_empty', 'min_length' => 2, 'max_length' => 256),
        'errors' => array(
            1 => 'Please supply your name!',
            2 => 'Please supply a longer name!',
            3 => 'Your name exceeds the maximum of 256 characters.',
            4 => 'Your name contains invalid characters!'
        )
    ),

    'Email' => array(
        'tagname' => 'input', 'type' => 'text',
        'wrapper_tag' => 'div', 'wrapper_attributes' => 'class="input"',
        'label' => 'Email Address', 'label_attributes' => '',
        'attributes' => 'type="text" maxlength="320"',
        'err_field_transform' => 'type="text" maxlength="320" class="field_error"',
        'err_wrap_tag' => 'div', 'err_wrap_attributes' => 'class="form_error"',
        'validate' => array('email'),
        'errors' => array(5 => 'Please enter a valid email address!')
    ),

    'Comment' => array(
        'tagname' => 'textarea',
        'wrapper_tag' => 'div', 'wrapper_atrributes' => 'class="textarea"',
        'label' => 'Message:', 'label_attributes' => '',
        'attributes' => 'cols="30" rows="4"',
        'err_field_transform' => 'cols="30" rows="4" class="field_error"',
        'err_wrap_tag' => 'div', 'err_wrap_attributes' => 'class="form_error"',
        'validate' => array('non_empty', 'min_length' => 5, 'max_length' => 2048),
        'errors' => array(
            1 => 'Please enter your message.',
            2 => 'Your message is too short!',
            3 => 'Your message exceeds 2048 characters'
        )
    ),

    'Delivery' => array(
        'tagname' => 'select',
        'wrapper_tag' => 'div', 'wrapper_attributes' => 'class="options"',
        'label' => 'Who would you like to talk to?', 'label_attributes' => '',
        'err_field_transform' => 'class="select_error"',
        'options' => array(
            0 => array(
                'nodeval' => '0', 'value' => 'Please choose one...',
                'selected' => 1),
            1 => array(
                'nodeval' => '1', 'value' => 'User 1' ),
            2 => array(
                'nodeval' => '2', 'value' => 'User 2' ),
            3 => array(
                'nodeval' => '3', 'value' => 'User 3' )
        )
    ),

    'Token' => array(
        'tagname' => 'input', 'type' => 'hidden',
        'attributes' => 'type="hidden"',
        'validate' => array(),
        'errors' => array()
    )
);


// Runtime settings for php.ini

ini_set('date.timezone', 'Europe/London');
ini_set('magic_quotes_runtime', '0');

ini_set('sendmail_from', $email_config['sendmail_from']);  // WIN32 causes Return-Path
ini_set('mbstring.language', 'Neutral');          // Set default language to Neutral(UTF-8) (default)
ini_set('mbstring.internal_encoding', 'UTF-8');   // Set default internal encoding to UTF-8
ini_set('mbstring.encoding_translation', 'On');   // HTTP input encoding translation is enabled
ini_set('mbstring.http_input', 'auto');           // Set HTTP input character set dectection to auto
ini_set('mbstring.http_output', 'UTF-8');         // Set HTTP output encoding to UTF-8
ini_set('mbstring.detect_order', 'auto');         // Set default character encoding detection order to auto
ini_set('mbstring.substitute_character', 'none'); // Do not print invalid characters
ini_set('default_charset', 'UTF-8');              // Default character set for auto content type header

ini_set('error_reporting', E_ALL | E_STRICT);
ini_set('display_errors', 'Off');
ini_set('log_errors', 'On');
ini_set('error_log', FORM_PARENT_PATH . '/error_log');  // TODO Logging.

ini_set('session.name', 'Visitor');
ini_set('session.cookie_httponly', '1');
